Skip to content

Dogfood the shared PHP-CS-Fixer config in CI#40

Merged
alies-dev merged 1 commit into
1.xfrom
dogfood-php-cs-fixer-ci
Jun 25, 2026
Merged

Dogfood the shared PHP-CS-Fixer config in CI#40
alies-dev merged 1 commit into
1.xfrom
dogfood-php-cs-fixer-ci

Conversation

@alies-dev

Copy link
Copy Markdown
Member

Summary

Follow-up to the PHP-CS-Fixer config work. The package never linted itself with its own shared config, so config regressions could ship unnoticed (that is how the @api-strip and the arrow/octal/numeric-separator surprises slipped through earlier). This adds a self-lint plus a strict CI gate.

Changes

  • .php-cs-fixer.dist.php — lints this package with Config::create(). Excludes vendor/.cache and the intentionally-malformed sniff test fixtures (tests/Sniffs/**, reformatting them would shift line numbers and break the sniff tests). Disables mb_str_functions: this package processes ASCII PHP tokens, not user-facing strings, so it should not pull in an ext-mbstring runtime dependency.
  • composer.jsonphp-cs-fixer (fix) and php-cs-fixer:check (dry-run) scripts.
  • .github/workflows/php-cs-fixer.yml — strict dry-run gate (mirrors psalm.yml). Intentionally a hard gate, not the auto-commit pattern of format_php.yml, so a rule renamed/removed by a Renovate bump fails loudly.
  • Applied the resulting formatting to the package source.
  • BladeTemplateExtractor — the phpcs:disable was a /** */ doc block; PHP-CS-Fixer expanded it to multi-line, which then tripped SlevomatCodingStandard.Commenting.RequireOneLineDocComment. Changed it to a line comment (a directive is not documentation). This conflict was found by the new self-lint.

Verification

  • composer php-cs-fixer:check exits 0 (idempotent).
  • vendor/bin/phpunit: 18 passing (fixtures untouched).
  • phpcs self-check: 0 errors.
  • composer validate: clean.

Add a .php-cs-fixer.dist.php that lints this package with its own shared config,
plus a strict PHP-CS-Fixer CI gate so a config regression (e.g. a rule renamed or
removed by a dependency bump) fails loudly instead of shipping unnoticed.

- .php-cs-fixer.dist.php: uses Config::create(); excludes vendor/.cache and the
  intentionally-malformed sniff test fixtures (tests/Sniffs/**); disables
  mb_str_functions (this package processes ASCII PHP tokens, not user-facing
  strings, so it should not pull in an ext-mbstring runtime dependency).
- composer.json: add `php-cs-fixer` and `php-cs-fixer:check` scripts.
- .github/workflows/php-cs-fixer.yml: strict dry-run gate (mirrors psalm.yml).
- Apply the resulting formatting to the package source.
- BladeTemplateExtractor: turn the `phpcs:disable` doc block into a line comment
  so PHP-CS-Fixer no longer expands it into a multi-line doc block that then
  conflicts with SlevomatCodingStandard.Commenting.RequireOneLineDocComment.
@alies-dev alies-dev merged commit d309521 into 1.x Jun 25, 2026
6 checks passed
@alies-dev alies-dev deleted the dogfood-php-cs-fixer-ci branch June 25, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant